home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr10 / nameclip.zip / NAMECLIP.S
Text File  |  1993-06-01  |  55KB  |  1,431 lines

  1. /****************************************************************************
  2.                        TSE Named Clipboard System
  3.  ****************************************************************************
  4.                                   Version 4
  5.                                **************
  6.  
  7.   Copyright: 1993 David Marcus
  8.  
  9.           Permission is granted to all persons for non-commercial
  10.           distribution of this file and the macros and ideas contained
  11.           herein provided (a) credit is given to the author and (b) all
  12.           changes not made by the author are attributed.
  13.  
  14.           Permission is granted to SemWare for commercial distribution
  15.           provided (a) and (b) above.
  16.  
  17.   Author:  David Marcus
  18.  
  19.   Date:    4-27-93
  20.  
  21.   Description:
  22.  
  23.           Nameclip is a macro system that implements named clipboards
  24.           and related functions in The Semware Editor.
  25.  
  26.    ╔════  ClipBoard Menu  ════╗   ┌───────────────────────┐
  27.    ║ Copy             <Grey+> ║   │                       v
  28.    ║ Copy Append <Ctrl Grey+> ║   │    ┌───────  ClipBoard Settings  ───────┐
  29.    ╟──────────────────────────╢   │    │ Clipboard Type           [  Named] │
  30.    ║ Cut              <Grey-> ║   │    │ Mode                    [Picklist] │
  31.    ║ Cut Append  <Ctrl Grey-> ║   │    │ Include Text on Picklists    [Yes] │
  32.    ╟──────────────────────────╢   │    ├────────────────────────────────────┤
  33.    ║ Paste            <Grey*> ║   │    │ Backup Clipboards       [      On] │
  34.    ║ Paste Over  <Ctrl Grey*> ║   │    ├────────────────────────────────────┤
  35.    ╟──────────────────────────╢   │    │ Use Current Line If No Block [Yes] │
  36.    ║ View Named Clipboard     ║   │    │ UnMark After Copy            [ No] │
  37.    ║ Rename Clipboard         ║   │    ├────────────────────────────────────┤
  38.    ║ Delete Named Clipboard   ║   │    │ UnMark After Paste           [ No] │
  39.    ╟──────────────────────────╢   │    │ Delete After Paste           [ No] │
  40.    ║ Settings...              ║>──┘    └────────────────────────────────────┘
  41.    ╟──────────────────────────╢
  42.    ║ Global Actions...        ║>──────────────┐
  43.    ╚══════════════════════════╝               │
  44.                                               v
  45.                              ┌─  ClipBoard Global Actions  ──┐
  46.                              │ Fill Clipboards From File     │
  47.                              │ Save All Clipboards to a File │
  48.                              ├───────────────────────────────┤
  49.                              │ Delete All Named Clipboards   │
  50.                              └───────────────────────────────┘
  51.  
  52.   Installation:
  53.  
  54.   1. Place file this in the directory where your configuration
  55.   (interface) files reside.  Add this line to your TSE.S (or other
  56.   configuration) file:
  57.  
  58.      #include ['nameclip.s']
  59.  
  60.   Place this line anywhere the file as long as it comes before your
  61.   menus.
  62.  
  63.   2. Delete any definitions you already have in your TSE.KEY file for
  64.   these keys:
  65.  
  66.      <f11>          ClipBoardMenu()
  67.      <Grey*>        ClipBoard_Menu_Action( PASTE_APPEND )
  68.      <Ctrl Grey*>   ClipBoard_Menu_Action( Paste_OVERWRITE )
  69.      <Ctrl PrtSc>   ClipBoard_Menu_Action( Paste_OVERWRITE )
  70.      <Grey+>        ClipBoard_Menu_Action( Copy_OverWrite )
  71.      <Ctrl Grey+>   ClipBoard_Menu_Action( Copy_APPEND )
  72.      <Grey->        ClipBoard_Menu_Action( Cut_OverWrite )
  73.      <Ctrl Grey->   ClipBoard_Menu_Action( Cut_APPEND )
  74.  
  75.   Or, change any of the key definitions included at the end of this
  76.   file to use keys you prefer.
  77.  
  78.   Or, delete the keydef() at the end of this file and run NameClip only
  79.   from menus.
  80.  
  81.   3. If you have a menu named ClipBoardMenu in your user interface file,
  82.   as you probably do, delete it or comment it out. This file contains a
  83.   substitution for it.
  84.  
  85.   4. Make sure that your main menu has a listing for ClipBoardMenu on
  86.   it; it should look something like this:
  87.  
  88.         "&Clipboard",   ClipboardMenu()
  89.  
  90.   5. Delete the main() procedure from this file; it is only useful if
  91.   you want to compile and use this file as an external macro file.
  92.  
  93.   6. Advanced Users: In NAMECLIP.S, the string ':U:' appears on each
  94.   line that contains the initial setting of a toggle or mode. Search for
  95.   :U: and customize as you like.  (Note: The initial settings for the
  96.   UnMarkAfterPaste and UseCurrentLineifNoBlock toggles comes from your
  97.   TSE configuration.)
  98.  
  99.   7. Re-bind the editor using the -b switch of sc.  If you receive any
  100.   "duplicate name" errors, delete the specified procedure from your
  101.   configuration file [NOT from nameclip.s] or comment it out, and
  102.   re-bind.
  103.  
  104.   8. (optional) Delete or comment out any procedures that sc reports as
  105.   "unused."
  106.  
  107.   9. (optional) Update your help file with any of the keys listed above.
  108.  
  109.  
  110.   Usage Notes:
  111.  
  112.      * "Delete after paste" option -- turn this ON when you have moved a
  113.        lot of stuff into clipboards and you want to make sure you move
  114.        it _all_ back into your file.
  115.  
  116.      * In NAMECLIP.S file, the string ':U:' appears on each line that
  117.        contains the initial setting of a toggle or mode.
  118.  
  119.        Search for :U: and customize as you like.  (Note: The initial
  120.        settings for the UnMarkAfterPaste and UseCurrentLineifNoBlock
  121.        toggles comes from your TSE configuration.)
  122.  
  123.      * "Mode" for Cut/Copy/Paste toggles between:
  124.  
  125.           QUICK - No picklists, no verification of overwrites of
  126.                existing clipboards. Clipboard name entries must be
  127.                typed.
  128.  
  129.           PICKLIST - Clipboards are selected from picklists. If <new> is
  130.                selected and an existing name is entered, overwrite
  131.                confirmation is requested.
  132.  
  133.      * Setting for automatic backup of clipboards can be:
  134.  
  135.           ON - If the clipboard to which you are doing a Copy or Cut
  136.                (without the append option) exists and has text, the text
  137.                is first copied to another clipboard. The backup
  138.                clipboard name is '■BAK■' + the name of the source
  139.                clipboard. If the backup clipboard already has text on
  140.                it, it is first deleted.
  141.  
  142.           ADDITIVE - Same as above except text on the backup clipboard
  143.                is not deleted. New text being copied to the clipboard is
  144.                added at the top of the clipboard. OFF - No backups.
  145.  
  146.        NOTE: Backups are not made when loading clipboards from a file.
  147.  
  148.      * When you use a clipboard with a zero-length name (i.e., just
  149.        press <enter> at the name prompt), NameClip uses the default
  150.        system clipboard.
  151.  
  152.        This means that if you start with the clipboard type set to
  153.        UNNAMED and then change to NAMED, the default TSE clipboard
  154.        contents are available. You'll see a blank name in picklists;
  155.        this is it.
  156.  
  157.      * If you Fill Clipboards from File, NameClip() does not check for
  158.        duplicate names. This may create multiple clipboards with the
  159.        same name; you can use the rename function to change them.
  160.  
  161.      * When the UseCurrentLineIfNoBlock optionis used, and block is
  162.        marked, the currentline is cut/copied. If UnMarkAfterCopy/Cut is
  163.        set to NO, it is left as the marked block.
  164.  
  165.      * Press <F11> for Clipboard Menu.
  166.  
  167.      * Use of a blank (null) name is allowed. This is handy when you
  168.        want to keep named clipboards turned on, but not use them much.
  169.        That's what I generally do.
  170.  
  171.      * NameClip integrates Tim Farley's WinClip macro to add Windows
  172.        clipboard support:
  173.  
  174.           1. The 'clipboard type' toggle goes NAMED/UNNAMED when TSE is
  175.              not being run in a Windows DOS Window. When it is in a DOS
  176.              Window, it toggles to WINDOWS, too.
  177.  
  178.           2. WINCLIP must be compiled and available as WINCLIP.MAC.
  179.  
  180.              If it is not available, NameCLip will still run fine but
  181.              you will not see WINDOWS as a possible clipboard type to
  182.              use. WINCLIP is available from the SemWare BBS.
  183.  
  184.              ╔══════════════════════════════════════════════════════════╗
  185.              ║ NOTE: This proc _must_ be added to WINCLIP:              ║
  186.              ║                                                          ║
  187.              ║ public proc IWCP()                                       ║
  188.              ║      SetGlobalInt( 'IWCP', IsWindowsClipboardPresent() ) ║
  189.              ║ end                                                      ║
  190.              ╚══════════════════════════════════════════════════════════╝
  191.  
  192.  **************************************************************************/
  193.  
  194. /**************************************************************************
  195.           Variable & Constant Declarations
  196.  **************************************************************************/
  197.  
  198. CONSTANT                           // for operation
  199.      COPY_OVERWRITE     = 10,           // NOTE: The order of these is
  200.      COPY_APPEND        = 20,           // critical because some comparisons
  201.      CUT_OVERWRITE      = 30,           // use checks such as
  202.      CUT_APPEND         = 40,           //   "IF FOO >= PASTE_APPEND ..."
  203.      GETTING_FROM_FILE  = 50,           // GETTING from file
  204.      PASTE_APPEND       = 60,
  205.      PASTE_OVERWRITE    = 70,
  206.      DELETE             = 80,
  207.      VIEW               = 90,
  208.      RENAME             = 100
  209.  
  210. CONSTANT                           // others
  211.      ADDITIVE = 2,                           // for backup types
  212.      NORMAL = 0,                             // for store_name_on_list mode
  213.      MAKING_BACKUP = 1,
  214.      UNNAMED = 0,                             // for clipboard_type
  215.      NAMED = 1,
  216.      WINDOWS = 2,
  217.      REPORT_STATUS = 0,                      // arg for toggles
  218.      CHANGE_STATUS = 1,
  219.      PICKLIST= 1,                            // mode
  220.      QUICK = 0
  221.  
  222. STRING
  223.      backup_str[5] = '■BAK■',                // :U: string prepended to buffer
  224.                                              //     name for backups. Must end
  225.                                              //     with other than a space.
  226.      new_option[34] = '99999        < new clipboard > ║',
  227.                                              // :U: Text added to top of list
  228.      title[20] = "Named ClipBoards",         // :U: Picklist title
  229.      buffer_flag[10]='■²Ço╕■',             // :U: Separates buffers in
  230.                                              //     saved file
  231.                                              //     Arbitrary, but unique
  232.      saveclipfilename[50]='!clipbrd.sav',    // :U: default file name
  233.      buffertext[53]='',                      // added to viewing list
  234. //     status[254] = '',                       // audit
  235.      BufferName[25] = '',                    // name of each buffer
  236.      new_BufferName[25] = '',                // for rename and backup
  237.      msg[32]=''
  238.  
  239. INTEGER
  240.      mode = PICKLIST,                        // :U: QUICK, PICKLIST
  241.      backup_type = ON,                       // :U: ON, OFF, ADDITIVE
  242.      clipboard_type = 1,                     // :U: NAMED, UNNAMED, WINDOWS
  243.      textflag = TRUE,                        // :U: include text on picklist?
  244.                                              //     TRUE, FALSE
  245.      unmark_flag = FALSE,                    // :U: unmark after copy
  246.                                              //     TRUE, FALSE
  247.      delete_after_paste = FALSE,             // :U: just what it says!
  248.                                              //     TRUE, FALSE
  249.      bid_width = 5,                          // chars allocated for bufferid
  250.      original_clip_ID,                       // original clip ID
  251.      buffer_to_use,                          // for named clipboard
  252.      sid,                                    // starting buffer
  253.      prompt_hist = 0,                        // history
  254.      clip_list_ID = 0,                       // buffer clipboard name list
  255.      max_width = 78,
  256.      operation,                              // menu-selected operation
  257.      msgl                                    // to hold starting msglevel
  258.  
  259. forward proc                  PopMessage( string title, integer mattr, integer xdelay )
  260.  
  261. /****************************************************************************
  262.      INSERTBUFFER()
  263.  ***************************************************************************/
  264. integer proc                  insertbuffer(integer id)
  265. //     status = 'ins_buff() ' + status
  266.      PushPosition()
  267.      PushBlock()         UnMarkBlock()
  268.      if GotoBufferID(id) and (NumLines() > 1 or CurrLineLen())
  269.           BegFile()      MarkLine()
  270.           EndFile()      MarkLine()
  271.      else
  272.           PopPosition()
  273.           PopBlock()
  274.           return(FALSE)
  275.      endif
  276.      PopPosition()
  277.      CopyBlock()
  278.      PopBlock()
  279.      return(TRUE)
  280. end
  281.  
  282. /****************************************************************************
  283.      BUFFERLINES()
  284.  ***************************************************************************/
  285. integer proc                  bufferlines(integer id)
  286. //     status = 'bufflines() ' + status
  287.      PushPosition()
  288.      if GotoBufferID(id) and (NumLines() > 1 or CurrLineLen())
  289.           PopPosition()
  290.           return(NumLines())
  291.      else
  292.           PopPosition()
  293.           return(0)
  294.      endif
  295.      return(TRUE)
  296. end
  297.  
  298. /****************************************************************************
  299.      mYESNOmenu()
  300.            A primitive YesNo menu that works under all circumstances.
  301.  ***************************************************************************/
  302. /****
  303. menu                          mYesNoMenu()
  304.      noEscape
  305.      "&No"    ,  , CloseBefore
  306.      "&Yes"   , , CloseBefore
  307.      "&Cancel", , CloseBefore
  308. end
  309.  
  310. /****************************************************************************
  311.      mYESNO(STRING question)
  312.  ***************************************************************************/
  313. /***
  314. integer proc                  mYesNo(string arg)
  315.      integer mba = Set( MenuBorderAttr, Query(MsgAttr) )
  316.      integer maxX, maxY, maxL, x1, y1
  317.      maxX = Query( ScreenCols )
  318.      maxY = Query( ScreenRows )
  319.      maxL = length( arg ) + 4
  320.      x1 = (maxX - maxL) / 2
  321.      Set(x1, iif( x1<0, 0, x1))
  322.      y1 = (maxY - SizeOf(myesnomenu) -2 )/ 2
  323.      Set(y1, iif( y1<0, 0, y1))
  324.      mYesNomenu(arg)
  325.      Set ( MenuBorderAttr, mba)
  326.      Return(MenuOption() - 1)           // return 0, 1, 2
  327. end
  328.  
  329. /****************************************************************************
  330.      X(INTEGER ARG)
  331.           A quickie helper to do a push or pop block -- but only when the
  332.           unmark after copy/cut flag is ON.
  333. ****************************************************************************/
  334. proc                          x(integer arg)
  335. //     status = 'x() ' + status
  336.  
  337.      if unmark_flag
  338.           return()
  339.      else
  340.           case arg
  341.                when 1 PushBlock()
  342.                when 2 PopBlock()
  343.           endcase
  344.      endif
  345. end
  346.  
  347. /****************************************************************************
  348.      SETUP_LIST_BUFFER()
  349.      Helper to set up the buffer for list of
  350.      clipboards.
  351. ****************************************************************************/
  352. proc                          setup_list_buffer()
  353. //     status = 'setup_list_buffer() ' + status
  354.      if clip_list_ID == 0
  355.           PushPosition()
  356.           clip_list_ID = CreateTempBuffer()
  357.           AddLine(new_option)
  358.           PopPosition()
  359.      endif
  360. end
  361.  
  362. /****************************************************************************
  363.      IF_LIST_EXISTS()
  364.           Helper to determine if clipboard list exists
  365.           and return buffer id
  366. ****************************************************************************/
  367. integer proc                  if_list_exists()
  368. //     status = 'if_list_exists() ' +  status
  369.      /*
  370.           Halts w/ msg if none exist
  371.           Else returns the id of the list buffer
  372.      */
  373.  
  374.      PushPosition()
  375.      if clip_list_ID and GotoBufferID(clip_list_ID)
  376.           if (operation >= PASTE_APPEND) and (NumLines() < 1)
  377.                goto bailout
  378.           else
  379.                PopPosition()
  380.                return(clip_list_ID)
  381.           endif
  382.      else
  383.           setup_list_buffer()
  384.           PopPosition()
  385.           if operation <> GETTING_FROM_FILE
  386.                goto bailout
  387.           endif
  388.      endif
  389.  
  390.      bailout:
  391.                msg = 'No named clipboards exist'
  392.                PopMessage( '', Query(MsgAttr), 18 )
  393.                PopPosition()
  394.                UpdateDisplay()
  395.                halt
  396.     return(42)
  397. end
  398.  
  399. /****************************************************************************
  400.      MARK_NAMES()
  401.           Helper to mark name area of cliplist
  402. ****************************************************************************/
  403. proc                          mark_names()
  404. //     status = 'mark_names() ' + status
  405.      UnMarkBLock()
  406.      Gotoline(2)    GotoPos(bid_width + 1)                    MarkColumn()
  407.      EndFile()      GotoPos(bid_width + Sizeof(buffername))   MarkColumn()
  408. end
  409.  
  410. /****************************************************************************
  411.      SORT_NAME_LIST()
  412.           Helper to sort list of names of clipboards
  413. ****************************************************************************/
  414. proc                          sort_name_list()
  415. //     status = 'sort_name_list() ' + status
  416.      PushPosition()
  417.      GotoBufferID(clip_list_ID)
  418.      PushBlock()
  419.      mark_names()
  420.      msgl = Set(MsgLevel, _NONE_)
  421.      sort(_IGNORE_CASE_)
  422.      Set(MsgLevel, msgl)
  423.      PopBlock()
  424.      PopPosition()
  425. end
  426.  
  427. /****************************************************************************
  428.      EXPANDED_ID()
  429.           Returns zero-filled buffer_id
  430.  ****************************************************************************/
  431. string  proc                  expanded_id()
  432.      return(Format(buffer_to_use:bid_width:'0'))
  433. end
  434.  
  435. /****************************************************************************
  436.      ADD_CONTENTS_TO_LIST()
  437.           Adds opening contents of buffer to the clipboard list buffer
  438. ***************************************************************************/
  439. proc                          add_contents_to_list()
  440. //     status = 'add_contents_to_list() ' + status
  441.      buffertext = ' ║ '
  442.      PushPosition()
  443.      GotoBufferID(buffer_to_use)
  444.      BegFile()
  445.      while Length(buffertext) < (SizeOf(buffertext)-3)
  446.           if PosLastNonWhite() == 0     // skip line if blank
  447.                if not Down()
  448.                     goto ending         // breaks out of while
  449.                endif
  450.           else                          // add line break indicator
  451.                if Length(buffertext) > 3
  452.                     buffertext = buffertext + ' │ '
  453.                endif
  454.                buffertext = buffertext + GetText( PosFirstNonWhite(),
  455.                               PosLastNonWhite() - PosFirstNonWhite() + 1 )
  456.                if not Down()
  457.                     goto ending
  458.                endif
  459.           endif
  460.      endwhile
  461.    ending:
  462.      GotoBufferID(clip_list_ID)
  463.      if not lFind(expanded_id(), '^g')
  464.           warn('hmmmmm....')
  465.      endif
  466.      GotoPos(bid_width + sizeof(buffername) + 1)
  467.      DeltoEol()
  468.      InsertText(buffertext, _OverWrite_)
  469.      PopPosition()
  470. end
  471.  
  472. /****************************************************************************
  473.      TRIM_BUFFERNAME() removes trailing spaces
  474. ****************************************************************************/
  475. proc                          trim_buffername()
  476. //     status = 'trim_buffername() ' + status
  477.      while length(buffername) AND buffername[length(buffername)] == ' '
  478.           buffername = substr(buffername, 1, length(buffername) -1)
  479.      endwhile
  480. end
  481.  
  482. /****************************************************************************
  483.      EXPAND_BUFFERNAME() removes trailing spaces
  484. ****************************************************************************/
  485. proc                          expand_buffername()
  486. //     status = 'expand_buffername() ' + status
  487.      buffername = format(buffername : - sizeof(buffername) : ' ')
  488. end
  489.  
  490. /****************************************************************************
  491.      GET_BUFF
  492.           Quickie to return the buffer number for the buffer on the
  493.           current line of clipboard list.
  494. ****************************************************************************/
  495. integer proc                  get_buff_num()
  496. //     status = 'gbn() ' + status
  497.      return( val(gettext(1,bid_width)) )
  498. end
  499.  
  500. /****************************************************************************
  501.      ADD_ENTRY_LINE()
  502.           Adds an entry to the clip_list buffer
  503.  ****************************************************************************/
  504. proc                          add_entry_line()
  505.      PushPosition()
  506.      GotoBufferID(clip_list_ID)
  507.      BegFile()
  508.      AddLine(expanded_id()+buffername)
  509.      PopPosition()
  510. end
  511.  
  512. /****************************************************************************
  513.      STORE_NAME_ON_LIST(INTEGER STORE_MODE)
  514.           Helper to store names of clipboards;
  515.           Create clipboard if does not exist;
  516.           Returns buffer id either way.
  517. ****************************************************************************/
  518. integer proc                  store_name_on_list(integer store_mode)
  519.      // store_mode = NORMAL for all operations except
  520.      // store_mode = BACKUPS when creating backup buffers
  521.  
  522. //     status = 'store_name_on_list() ' + status
  523.      sid = getbufferid()
  524.      GotoBufferID(if_list_exists())          // Goto list buffer
  525.                                              // warns & halts if no exist
  526.      /*
  527.           Mark for Local Search (to exclude IDs)
  528.      */
  529.      PushBlock()
  530.      mark_names()
  531.    xtop:
  532.      expand_buffername()
  533.      if not lFind(buffername, '^gli')              // if not find 'name'
  534.           PopBlock()
  535.           if not (buffer_to_use == original_clip_id) or
  536.              (store_mode == 1)
  537.                buffer_to_use = CreateTempBuffer()  // create buffer
  538.           endif                                    // if not original
  539.           if not buffer_to_use
  540.                message('Err 2a')              // Create buffer failed
  541.                halt
  542.           endif
  543.           add_entry_line()
  544.           sort_name_list()
  545.           lFind(buffername, 'gin')           // position to last add
  546.           goto ending
  547.      endif
  548.      trim_buffername()
  549.  
  550.      if ( store_mode <> MAKING_BACKUP ) and  // i.e., isn't a backup buffer
  551.         ( mode <> QUICK ) and                // picklists are being used
  552.         (Operation < VIEW ) and
  553.         length(buffername)                   // no query to overwrite unnamed
  554.  
  555.           case YesNo(buffername+ ' exists; overwrite?')
  556.                when 2                        // re-ask
  557.                     if not Ask(Msg, BufferName, prompt_hist) and Length(buffername)
  558.                          PopBlock()
  559.                          GotoBufferID(sid)
  560.                          halt
  561.                     endif
  562.                     goto xtop
  563.                when 1                        // overwrite
  564.                     buffer_to_use = get_buff_num()
  565.                     PopBlock()
  566.                otherwise                     // bail out for esc, cancel
  567.                     PopBlock()
  568.                     GotoBufferID(sid)
  569.                     halt
  570.           endcase
  571.      else                                    // is a backup buffer
  572.           buffer_to_use = get_buff_num()     // so no overwrite prompt
  573.           PopBlock()
  574.      endif
  575.    ending:
  576.      GotoBufferID(sid)
  577.      return(buffer_to_use)
  578. end
  579.  
  580. /****************************************************************************
  581.      MARK_IDS()
  582.           Help to mark id section of cliplist as a block.
  583. ****************************************************************************/
  584. proc                          mark_ids()
  585.  
  586. //     status = 'mark_ids() ' + status
  587.      PushPosition()
  588.      PushBlock()    UnMarkBLock()
  589.      BegFile()      GotoPos(1)             MarkColumn()
  590.      EndFile()      GotoPos(bid_width)     MarkColumn()
  591.      PopPosition()
  592. end
  593.  
  594. /****************************************************************************
  595.      LISTCLIPS():
  596.           Helper to list named clipboards
  597.           and return the bufferid of the selected one, if any
  598.           or return 0 if <esc>
  599. ****************************************************************************/
  600. integer proc                  ListClips()
  601.      integer
  602.           deleted = FALSE                    // flag
  603. //     status = 'ListClips() ' + status
  604.  
  605.      if mode == QUICK
  606.           return(99999)
  607.      endif
  608.  
  609.      sid = getbufferid()                     // starting bufferid
  610.  
  611.      if GotoBufferID( if_list_exists() )
  612.           if NumLines() <= 1                 // no named clipboards
  613.                GotoBufferID(sid)
  614.                return(99999)                 // 'create new' code
  615.           endif
  616.      endif
  617.  
  618.      if operation > GETTING_FROM_FILE
  619.           lfind(expanded_id(),'g')
  620.      endif
  621.  
  622.      /*
  623.           Delete bufferIDs before listing
  624.      */
  625.      PushBlock()
  626.      mark_ids()
  627.      DelBlock()
  628.  
  629.      /*
  630.           Delete 'new clipboard' option for certain ops
  631.      */
  632.      if operation > GETTING_FROM_FILE
  633.           PushPosition()
  634.           BegFile()
  635.           DelLine()
  636.           PopPosition()
  637.           deleted = TRUE
  638.      else
  639.           BegFile()                     // set default to <new>
  640.                                         // for copy & cut
  641.  
  642.      endif
  643.                                              // set list location
  644.      Set(Y1,2)                               // line two
  645.      Set(X1,                                 // right justified
  646.          iif(textflag, Query (ScreenCols) - max_width - 1,
  647.                        Query (ScreenCols) - SizeOf(buffername) - 2))
  648.      if lList( title,
  649.                iif(textflag, max_width + 1, SizeOf(buffername) + 2),
  650.                iif(NumLines() > 20, NumLines(), 20), _ENABLE_SEARCH_ )
  651.           PushPosition()
  652.           BegFile()
  653.           /*
  654.                Restore 'new clipboard' option
  655.           */
  656.           if deleted
  657.                UnDelete()
  658.           endif
  659.  
  660.           /*
  661.                Restore buffer IDs
  662.           */
  663.           UnDelete()
  664.  
  665.           PopPosition()
  666.           PopBlock()     //----------
  667.           buffer_to_use = get_buff_num()          // get the bufferid of
  668.                                                   // the selected clipboard
  669.           if buffer_to_use <> 99999               // 99999 is 'create new' flag
  670.                buffername = gettext(bid_width+1, sizeof(buffername))
  671.                trim_buffername()
  672.                AddHistoryStr(buffername,prompt_hist)
  673.           endif
  674.      else                                    // <esc> was pressed
  675.           buffer_to_use = 0
  676.           PushPosition()
  677.           BegFile()
  678.           /*
  679.                Restore 'new clipboard' option
  680.           */
  681.           if deleted
  682.                UnDelete()
  683.           endif
  684.           /*
  685.                Restore buffer IDs
  686.           */
  687.           UnDelete()
  688.           PopPosition()
  689.      endif
  690.      PopBlock()
  691.      GotoBufferID(sid)
  692.      return(buffer_to_use)                       // 0 if <esc> for list
  693. end
  694.  
  695. /****************************************************************************
  696.      DELETE_NAMED_CLIPBOARD(INTEGER xMODE)
  697. ****************************************************************************/
  698.      // mode = 0 for all operations except
  699.      // mode = 1 when deleting after Paste
  700. proc                          delete_named_clipboard(integer xmode)
  701. //     status = 'delete_named_clipboard() ' + status
  702.      sid = getbufferid()
  703.      operation = DELETE
  704.      PushPosition()
  705.      GotoBufferID( if_list_exists() )
  706.  
  707.      if xmode == 0
  708.           ListClips()                        // set buffer_to_use
  709.      endif
  710.  
  711.      GotoBufferID(sid)
  712.  
  713.      if buffer_to_use
  714.           if GotoBufferID( if_list_exists() )
  715.                mark_ids()
  716.                if lFind(expanded_id(), 'glin')
  717.                   DelLine()
  718.                   if NumLines() == 1 and CurrLineLen() == 0
  719.                     AbandonFile()
  720.                     clip_list_ID = 0
  721.                   endif
  722.                   if GotoBufferID(buffer_to_use)
  723.                       AbandonFile()
  724.                   else
  725.                       message('Err 3')       // got buffer id but Goto
  726.                       halt                   // failed
  727.                   endif
  728.                else
  729.                   message('Err 4')           // got id but can't find
  730.                   halt
  731.                endif
  732.            endif
  733.      endif
  734.      PopPosition()
  735.      PopBlock()
  736. end
  737.  
  738. /****************************************************************************
  739.      GET_NAME_FROM_ID()
  740.           Helper to get name
  741. ****************************************************************************/
  742. string proc                   get_name_from_id()
  743. //     status = 'get_name_from_id() ' + status
  744.      PushPosition()
  745.      GotoBufferID(clip_list_ID)
  746.      lFind(expanded_id() , '^g')
  747.      buffername = GetText(bid_width+1, PosLastNonWhite())
  748.      PopPosition()
  749.      return(buffername)
  750. end
  751.  
  752. /****************************************************************************
  753.      DELETE_ALL_NAMED_CLIPBOARDS()
  754. ***************************************************************************/
  755. proc                          delete_all_named_clipboards()
  756.      integer
  757.           id
  758.      sid = getbufferid()
  759.      GotoBufferID(if_list_exists())
  760.      BegFile()
  761.      GotoLine(2)
  762.      while NumLines() >= CurrLine() AND CurrLineLen() > 0
  763.           buffer_to_use = get_buff_num()
  764.           msg = get_name_from_id()
  765.           PopMessage('Deleting...', Query(MsgAttr), 12)
  766.           AbandonFile(get_buff_num())
  767.           DelLine()
  768.      endwhile
  769.      AbandonFile()
  770.      clip_list_id = 0
  771.      gotobufferid(sid)
  772. end
  773.  
  774. /****************************************************************************
  775.      VIEW_NAMED_CLIPBOARD()
  776. ****************************************************************************/
  777. proc                          view_named_clipboard()
  778.      operation = VIEW
  779.  
  780.      PushPosition()
  781.      GotoBufferID( if_list_exists() )
  782.      buffer_to_use = ListClips()                        // get list of clips
  783.      if buffer_to_use
  784.           buffername = get_name_from_ID()
  785.           trim_buffername()
  786.           if GotoBufferID(buffer_to_use)
  787.                list(buffername,80)
  788.           else
  789.                warn('Err 4')
  790.           endif
  791.      endif
  792.      PopPosition()
  793. end
  794.  
  795. /****************************************************************************
  796.      BACKUP()
  797.           This is the macro that handles backup before cut and copy.
  798. ****************************************************************************/
  799.  
  800. proc                          backup()
  801.      integer
  802.           primary_buffer = 0
  803.      if backup_type and
  804.         bufferlines(buffer_to_use)                // if there are contents
  805.           PushPosition()
  806.           new_buffername = buffername
  807.           primary_buffer=buffer_to_use
  808.           buffername = backup_str + buffername    // setup .bak name
  809.           store_name_on_list(MAKING_BACKUP)       // sets buffer_to_use to
  810.                                                   // .bak buffer
  811.           GotoBufferID(buffer_to_use)
  812.           if backup_type <> ADDITIVE              // if not additive
  813.                PushBlock()                        // delete contents
  814.                BegFile() MarkLine()
  815.                EndFile() MarkLine()
  816.                DelBlock()
  817.                PopBlock()
  818.           endif
  819.           insertbuffer(primary_buffer)
  820.           add_contents_to_list()
  821.           PopPosition()
  822.           buffer_to_use = primary_buffer          // reset for the copy/cut
  823.           buffername = new_buffername             //     from the text file
  824.      endif
  825. end
  826.  
  827. /****************************************************************************
  828.      NAMED_CLIPBOARD()
  829.           This is the macro that handles all named clipboard operations.
  830. ****************************************************************************/
  831. integer proc                  named_clipboard()
  832.      integer marked = FALSE                  // was curr line marked?
  833.      /*
  834.           Save current ClipBoard Id
  835.      */
  836.      original_clip_ID = GetClipBoardId()
  837.  
  838.      /*
  839.           Make sure the history buffer has been setup
  840.      */
  841.      if prompt_hist == 0
  842.           prompt_hist = GetFreeHistory()
  843.      endif
  844.  
  845.      /*
  846.           Make sure the list of names buffer has been setup
  847.      */
  848.      setup_list_buffer()
  849.  
  850.      /*
  851.           Saves (Cut/Copy) require a marked block in the current buffer
  852.           unless UseCurrLineIfNoBlock is On
  853.      */
  854.      if Operation <= CUT_APPEND
  855.         AND Query(BlockId) <> GetBufferId()
  856.           if query(usecurrlineifnoblock) == TRUE
  857.                UnMarkBlock()
  858.                MarkLine()
  859.                MarkLine()
  860.                marked = true
  861.           else
  862.                msg = 'Block must be in current file'
  863.                popmessage('', query(MsgAttr), 0)
  864.                return (FALSE)
  865.           endif
  866.      endif
  867.  
  868.      /*
  869.           Set up user prompt/message used when prompting for name of CB
  870.      */
  871.      case Operation
  872.           when COPY_OVERWRITE    Msg = "Copy"
  873.           when COPY_APPEND       Msg = "Copy/Append"
  874.           when CUT_OVERWRITE     Msg = "Cut"
  875.           when CUT_APPEND        Msg = "Cut/Append"
  876.      endcase
  877.      msg = msg +' to clipboard:'
  878.  
  879.      BufferName = ""
  880.      buffer_to_use = ListClips()
  881.      if buffer_to_use == 99999               // if 'create new'
  882.           trim_buffername()
  883.           if not Ask(Msg, BufferName, prompt_hist)
  884.                if marked
  885.                     UnMarkBlock()
  886.                endif
  887.                return(FALSE)                 // return if <esc>
  888.           elseif not Length(buffername)
  889.                buffer_to_use = original_clip_id
  890.                SetClipBoardId( store_name_on_list(NORMAL) )
  891.           else
  892.                SetClipBoardId( store_name_on_list(NORMAL) )
  893.           endif
  894.      elseif buffer_to_use == 0               // if returns 0 (<esc>)
  895.           if marked
  896.                UnMarkBlock()
  897.           endif
  898.           return(FALSE)
  899.      elseif buffer_to_use                    // else set ID
  900.           SetClipBoardId( buffer_to_use )
  901.      endif
  902.  
  903.      case Operation
  904.           when COPY_OVERWRITE    x(1)
  905.                                  backup()
  906.                                  Copy()
  907.                                  x(2)
  908.           when COPY_APPEND       x(1)
  909.                                  Copy(_APPEND_)
  910.                                  x(2)
  911.           when CUT_OVERWRITE     backup()
  912.                                  Cut()
  913.           when CUT_APPEND        Cut(_APPEND_)
  914.  
  915.           when PASTE_APPEND      if Paste() and delete_after_paste
  916.                                    delete_named_clipboard(1)
  917.                                  endif
  918.           when PASTE_OVERWRITE   if Paste(_OVERWRITE_) and delete_after_paste
  919.                                    delete_named_clipboard(1)
  920.                                  endif
  921.      endcase
  922.  
  923.      /*
  924.           Add text to clipboard listing
  925.      */
  926.      if operation >= COPY_OVERWRITE AND
  927.         operation <= CUT_APPEND
  928.           add_contents_to_list()
  929.      endif
  930.  
  931.      // Restore ClipBoard
  932.      SetClipBoardId( original_clip_ID )
  933.      set(BREAK,OFF)
  934.      return(TRUE)
  935. end
  936.  
  937. /****************************************************************************
  938.      TOGGLE_TEXTFLAG():
  939.           Toggles whether to include first bit of text in list of clipboards
  940. ****************************************************************************/
  941. proc                          toggle_textflag()
  942.      textflag = NOT textflag
  943. end
  944.  
  945. /****************************************************************************
  946.      TOGGLE_UNMARK():
  947.           Toggles whether to unmark after Cut/Copy
  948. ****************************************************************************/
  949. proc                          toggle_unmark()
  950.      unmark_flag = NOT unmark_flag
  951. end
  952.  
  953. /****************************************************************************
  954.      TOGGLE_DELETE_AFTER_PASTE():
  955.           Toggles whether to delete the clipboard after Cut/Copy
  956. ****************************************************************************/
  957. proc                          toggle_delete_after_paste()
  958.      delete_after_paste = NOT delete_after_paste
  959. end
  960.  
  961. /****************************************************************************
  962.      TOGGLE_MODE(INTEGER ARG)
  963.           Toggles picklist vs quick
  964. ****************************************************************************/
  965. string proc                   toggle_mode(integer arg)
  966.      case arg
  967.           when REPORT_STATUS
  968.                case mode
  969.                     when PICKLIST return ('Picklist')
  970.                     when QUICK return ('Quick')
  971.                     when ADDITIVE return('Additive')
  972.                endcase
  973.           when CHANGE_STATUS
  974.                mode = not mode
  975.      endcase
  976.      return('')
  977. end
  978.  
  979. /****************************************************************************
  980.      TOGGLE_backup_type(INTEGER ARG)
  981.           Toggles backup type.
  982. ****************************************************************************/
  983. string proc                   toggle_back_type(integer arg)
  984.      case arg
  985.           when REPORT_STATUS
  986.                case backup_type
  987.                     when OFF return('Off')
  988.                     when ON return('On')
  989.                     when ADDITIVE return('Additive')
  990.                endcase
  991.           when CHANGE_STATUS
  992.                backup_type = (backup_type + 1) Mod 3
  993.      endcase
  994.      return('')
  995. end
  996.  
  997. /****************************************************************************
  998.      TOGGLE_CLIP_TYPE(INTEGER ARG)
  999.           Toggles clipboard type.
  1000.           If WINCLIP.MAC is present it is loaded so that
  1001.                presence of Windows clipboard can be tested
  1002.                to see if OK to toggle type to WINDOWS.
  1003. ****************************************************************************/
  1004. string proc                   toggle_clip_type(integer arg)
  1005.      case arg
  1006.           when REPORT_STATUS
  1007.                case clipboard_type
  1008.                     when UNNAMED return('UnNamed')
  1009.                     when NAMED return('Named')
  1010.                     when WINDOWS return('Windows')
  1011.                endcase
  1012.           when CHANGE_STATUS
  1013.                msgl = set(msglevel,_NONE_)
  1014.                if loadmacro('winclip')
  1015.                     Set(MsgLevel,msgl)
  1016.                     ExecMacro('IWCP')
  1017.                     clipboard_type =
  1018.                     (clipboard_type + 1)
  1019.                          Mod ( iif(GetGlobalInt('IWCP'), 3, 2) )
  1020.                else
  1021.                     Set(MsgLevel,msgl)
  1022.                     clipboard_type = NOT clipboard_type
  1023.                endif
  1024.      endcase
  1025.      Set(MsgLevel,msgl)
  1026.      if clipboard_type == NAMED                     // just changed to NAMED
  1027.           PushPosition()                         // so add system clipboard
  1028.           original_clip_id = GetClipboardID()    // to clip_list
  1029.           gotobufferid(original_clip_id)
  1030.           if NumLines() > 0
  1031.                buffer_to_use = original_clip_id
  1032.                buffername = ''
  1033.                setup_list_buffer()
  1034.                store_name_on_list(NORMAL)
  1035.                add_contents_to_list()
  1036.           endif
  1037.           PopPosition()
  1038.      endif
  1039.  
  1040.      return('')
  1041. end
  1042.  
  1043. /****************************************************************************
  1044.      CLIPBOARD_MENU_ACTION(INTEGER ACTION)
  1045.           This macro handles unnamed and windows clipboard operations.
  1046.           It branches to named_clipboard() for named clipboard ops.
  1047.           It also takes care of the UnMarkAfterPaste operation, if set,
  1048.                for all clipboard types.
  1049. ****************************************************************************/
  1050. proc                          clipboard_menu_action(integer Action)
  1051.     operation = action                 // set global integer with action
  1052.  
  1053.     if clipboard_type == 2 AND (NOT IsMacroLoaded('winclip'))
  1054.         LoadMacro('winclip')
  1055.     endif
  1056.  
  1057.     if Query(unmarkafterpaste) AND (action == PASTE_APPEND or
  1058.                                     action == PASTE_OVERWRITE)
  1059.         PushBlock()
  1060.     endif
  1061.  
  1062.     case clipboard_type
  1063.         when NAMED
  1064.              named_clipboard()
  1065.         when UNNAMED
  1066.              case action
  1067.                  when COPY_OVERWRITE    x(1) Copy() x(2)
  1068.                  when COPY_APPEND       x(1) Copy(_APPEND_)  x(2)
  1069.                  when PASTE_APPEND      Paste()
  1070.                  when PASTE_OVERWRITE   Paste(_OVERWRITE_)
  1071.                  when CUT_OVERWRITE     Cut()
  1072.                  when CUT_APPEND        Cut(_APPEND_)
  1073.              endcase
  1074.          when WINDOWS
  1075.              case action
  1076.                  when COPY_OVERWRITE    x(1) Copy() ExecMacro('CopytoWindows') x(2)
  1077.                  when COPY_APPEND       message('Cannot APPEND to Windows clipboard')
  1078.                  when PASTE_APPEND      ExecMacro('PasteFromWindows') Paste()
  1079.                  when PASTE_OVERWRITE   message('Cannot OVERWRITE from Windows clipboard')
  1080.                  when CUT_OVERWRITE     Cut() ExecMacro('CopytoWindows')
  1081.                  when CUT_APPEND        message('Cannot APPEND to Windows clipboard')
  1082.              endcase
  1083.      endcase
  1084.  
  1085.      if Query(unmarkafterpaste) and (action == PASTE_APPEND OR
  1086.                                      action == PASTE_OVERWRITE)
  1087.         PopBlock()
  1088.      endif
  1089.  
  1090.     // Done
  1091.     return ()
  1092. end
  1093.  
  1094. /****************************************************************************
  1095.      SAVECLIPS()
  1096. ****************************************************************************/
  1097. proc                          SaveClips()
  1098.      integer
  1099.           scf=0                       // working buffer
  1100.      clip_list_id = if_list_exists()  // will halt w/error if no name clips
  1101.      original_clip_ID = GetClipBoardId()
  1102.      PushPosition()
  1103.  
  1104.      /*
  1105.           Get file name
  1106.      */
  1107.      askfile:
  1108.      if Ask('File name for clipboard storage?', saveclipfilename)
  1109.           and Length(saveclipfilename)
  1110.      else
  1111.           goto ending
  1112.      endif
  1113.  
  1114.      /*
  1115.           Verify replacement if exists
  1116.      */
  1117.      if FileExists(saveclipfilename)
  1118.           case YesNo('Overwrite '+saveclipfilename+ '?')
  1119.                when 2 goto askfile      // No
  1120.                when 0,3 goto ending     // Esc, Cancel
  1121.           endcase
  1122.      endif
  1123.  
  1124.      /*
  1125.           If file is loaded, get rid of it
  1126.      */
  1127.      msgl = set(msgLevel, _NONE_)
  1128.      if EditFile(saveclipfilename)
  1129.           AbandonFile()
  1130.      endif
  1131.      set(msgLevel, msgl)
  1132.  
  1133.      scf = CreateBuffer(saveclipfilename)
  1134.      GotoBufferID(clip_list_id)
  1135.      BegFile()
  1136.      while Down()
  1137.           SetClipBoardId( get_buff_num() )
  1138.           buffername = GetText(bid_width+1, CurrLineLen() - bid_width)
  1139.           msg = buffername
  1140.           PopMessage('Processing...', Query(MsgAttr), 12)
  1141.           GotoBufferID(scf)
  1142.           AddLine(buffer_flag + buffername)
  1143.           AddLine()
  1144.           Paste()
  1145.           EndFile()
  1146.           GotoBufferID(clip_list_id)
  1147.      endwhile
  1148.      GotoBufferID(scf)
  1149.      msgl = set(MsgLevel, _NONE_)
  1150.      if SaveFile()
  1151.           AbandonFile()
  1152.      else
  1153.           msg = "Couldn't save; keeping file"
  1154.           PopMessage('', query(MsgAttr), 0)
  1155.      endif
  1156.      set(MsgLevel, msgl)
  1157.      ending:
  1158.           SetClipBoardID(original_clip_ID)
  1159.           PopPosition()
  1160. end
  1161.  
  1162. /****************************************************************************
  1163.      RENAME_IT(STRING OLD_NAME, STRING NEW_NAME)
  1164. ****************************************************************************/
  1165. proc                          rename_it(STRING old_name, STRING new_name)
  1166. //     status = 'rename_it() ' + status
  1167.      GotoBufferID(clip_list_ID)
  1168.      buffername = old_name
  1169.      expand_buffername()
  1170.      if not lFind(expanded_id() + buffername, '^g')
  1171.           msg = "Err 5"
  1172.           PopMessage('', query(MsgAttr), 0)
  1173.           halt
  1174.      endif
  1175.      GotoPos(bid_width + 1)
  1176.      buffername = new_name
  1177.      expand_buffername()
  1178.      InsertText(buffername, _OVERWRITE_)
  1179. end
  1180.  
  1181. /****************************************************************************
  1182.      RENAME_CLIPBOARD()
  1183. ****************************************************************************/
  1184. proc                          rename_clipboard()
  1185.      new_buffername=''
  1186.      sid = GetBufferID()
  1187.      operation = RENAME
  1188.      buffer_to_use = ListClips()
  1189.      if not buffer_to_use
  1190.           goto ending
  1191.      endif
  1192.      buffername = get_name_from_ID()
  1193.      trim_buffername()
  1194.      if Ask('New name for ' +  buffername + '?', new_buffername, prompt_hist) AND
  1195.           Length(new_buffername)
  1196.           rename_it(buffername, new_buffername)
  1197.           sort_name_list()
  1198.      endif
  1199.      ending:
  1200.           GotoBufferID(sid)
  1201.  
  1202. end
  1203.  
  1204. /****************************************************************************
  1205.      STORE_IT()
  1206. ****************************************************************************/
  1207. proc                          store_it()
  1208.      PushPosition()
  1209. //   GotoBufferID(if_list_exists())          // Goto list buffer
  1210.  
  1211.      /*
  1212.           Create Buffer and Copy
  1213.      */
  1214.      buffer_to_use = CreateTempBuffer() // create buffer
  1215.      if not buffer_to_use
  1216.           message('Err 2b')              // Create buffer failed
  1217.           halt
  1218.      endif
  1219.      CopyBlock()
  1220.  
  1221.      /*
  1222.           Add to list
  1223.      */
  1224.      GotoBufferID(clip_list_ID)         // return to list
  1225.      BegFile()
  1226.  
  1227.      /*
  1228.           Check for Dupes ------ NOT WORKING; COMMENTED OUT
  1229.      PushBlock()
  1230.      mark_names()
  1231.      if lFind(buffername, 'gl')
  1232.           trim_buffername()
  1233.           case YesNo('Replace current ' + buffername + '?')
  1234.                when 2                        // NO
  1235.                     ask('Alternate name?', buffername, prompt_hist)
  1236. //                  AbandonFile(get_buff_num())
  1237.   //                DelLine()
  1238.                when 1                        // YES
  1239.                     warn(buffername)
  1240.                     buffer_to_use = get_buff_num()
  1241.                     rename_it(buffername, buffername + ''+ saveclipfilename)
  1242.                     buffername = substr(buffername, 1, pos('', buffername)-1)
  1243.                otherwise
  1244.                     popposition()
  1245.                     halt
  1246.           endcase
  1247.      endif
  1248.      PopBlock()
  1249.      */
  1250.      add_entry_line()
  1251.      add_contents_to_list()
  1252.      PopPosition()
  1253. end
  1254.  
  1255. /****************************************************************************
  1256.      GETCLIPS()
  1257. ****************************************************************************/
  1258. proc                          GetClips()
  1259.      integer
  1260.           temp,                              // temp buffer holds get file
  1261.           buffer                             // used to hold buffer #s
  1262.  
  1263.      original_clip_ID = GetClipBoardId()
  1264.      operation = GETTING_FROM_FILE
  1265.  
  1266.      setup_list_buffer()                     // just in case?
  1267.      PushPosition()
  1268.      PushBlock()
  1269.  
  1270.      if Ask('File name for clipboards?', saveclipfilename)
  1271.           AND Length(saveclipfilename)
  1272.      else
  1273.           msg = 'bad file name'
  1274.           PopMessage('', Query(MsgAttr), 19)
  1275.           goto ending
  1276.      endif
  1277.  
  1278.      temp = CreateTempBuffer()
  1279.      msgl = set(msglevel, _NONE_)
  1280.      InsertFile(saveclipfilename)
  1281.      set(msglevel, msgl)
  1282.  
  1283.      while lFind(buffer_flag, '^')
  1284.           UnMarkBLock()
  1285.           buffername = GetText(Length(buffer_flag)+1,
  1286.                                CurrLineLen()-Length(buffer_flag))
  1287.           Down()
  1288.           MarkLine()
  1289.           if lFind(buffer_flag, '^')
  1290.                Up()
  1291.                MarkLine()
  1292.           else
  1293.                EndFile()
  1294.                MarkLine()
  1295.           endif
  1296.           store_it()
  1297.           GotoBufferID(temp)
  1298.           msg = buffername
  1299.           PopMessage('Processing...', Query(MsgAttr), 12)
  1300.      endwhile
  1301.  
  1302.      sort_name_list()
  1303.  
  1304.      ending:
  1305.           AbandonFile(temp)
  1306.           PopBlock()
  1307.           SetClipBoardID(original_clip_ID)
  1308.           PopPosition()
  1309. end
  1310.  
  1311. /****************************************************************************
  1312.      CLIPBOARD_SETTINGS_MENU()
  1313. ****************************************************************************/
  1314. Menu                          Clipboard_Settings_Menu()
  1315.       History
  1316.       Title = ' ClipBoard Settings '
  1317.  
  1318.      "Clipboard &Type"    [toggle_clip_type(REPORT_STATUS):7] ,
  1319.           toggle_clip_type(CHANGE_STATUS)                        , DontClose
  1320.      "&Mode"              [toggle_mode(REPORT_STATUS):8],
  1321.           toggle_mode(CHANGE_STATUS)                             , DontClose
  1322.      "&Include Text on Picklists" [ iif(textflag,'Yes', 'No') : 3] ,
  1323.           toggle_textflag()                                      , DontClose
  1324.       ""                                                ,        , Divide
  1325.      "&Backup Clipboards" [toggle_back_type(REPORT_STATUS):8] ,
  1326.           toggle_back_type(CHANGE_STATUS)                        , DontClose
  1327.      ""                                                 ,         , Divide
  1328.      "&Use Current Line If No Block" [iif(Query(UseCurrLineIfNoBlock),'Yes', 'No') : 3] ,
  1329.           toggle(UseCurrLineIfNoBlock)                           , DontClose
  1330.      "UnMa&rk After Copy"[ iif(unmark_flag,'Yes', 'No') : 3] ,
  1331.           toggle_unmark()                                        , DontClose
  1332.      ""                                                         , , Divide
  1333.      "UnMar&k After Paste"[iif(query(unmarkafterpaste),'Yes', 'No') : 3] ,
  1334.           toggle(unmarkafterpaste)                               , DontClose
  1335.      "&Delete After Paste"[ iif(delete_after_paste,'Yes', 'No') : 3] ,
  1336.           toggle_delete_after_paste()                            , DontClose end
  1337.  
  1338. /****************************************************************************
  1339.      GLOBAL_CLIPBOARD_MENU()
  1340. ****************************************************************************/
  1341. Menu                          Global_Clipboard_Menu()
  1342.           History
  1343.           Title = ' ClipBoard Global Actions '
  1344.     "&Fill Clipboards From File",     GetClips()                    , CloseBefore
  1345.     "&Save All Clipboards to a File", SaveClips()                   , CloseBefore
  1346.      ""                 ,                                           , Divide
  1347.     "&Delete All Named Clipboards"
  1348.                         ,   delete_all_named_clipboards()           , CloseBefore
  1349. end
  1350.  
  1351. /****************************************************************************
  1352.      CLIPBOARDMENU()
  1353. ****************************************************************************/
  1354. Menu                          ClipBoardMenu()
  1355.           History
  1356.           Title = ' ClipBoard Menu '
  1357.     "&Copy"             ,   clipboard_menu_action( COPY_OVERWRITE ) , CloseAllBefore
  1358.     "Copy &Append"      ,   clipboard_menu_action( COPY_APPEND )    , CloseAllBefore
  1359.     ""                  ,                                           , Divide
  1360.     "C&ut"              ,   clipboard_menu_action( CUT_OVERWRITE )  , CloseAllBefore
  1361.     "Cu&t Append "      ,   clipboard_menu_action( CUT_APPEND )     , CloseAllBefore
  1362.     ""                  ,                                           , Divide
  1363.     "&Paste"            ,   clipboard_menu_action( PASTE_APPEND )   , CloseAllBefore
  1364.     "Paste &Over"       ,   clipboard_menu_action( PASTE_OVERWRITE ), CloseAllBefore
  1365.     ""                  ,                                           , Divide
  1366.     "&View Named Clipboard"
  1367.                         ,   view_named_clipboard()                  , DontClose
  1368.     "R&ename Clipboard"
  1369.                         ,   rename_clipboard()                      , DontClose
  1370.     "&Delete Named Clipboard"
  1371.                         ,   delete_named_clipboard(0)               , DontClose
  1372.     ""                  ,                                           , Divide
  1373.     "&Settings..."      ,   Clipboard_Settings_Menu()               , DontClose
  1374.     ""                  ,                                           , Divide
  1375.     "&Global Actions...",   Global_Clipboard_Menu()                 , DontClose
  1376. end
  1377.  
  1378. /****************************************************************************
  1379.      POPMESSAGE( STRING TITLE, STRING MSG, INTEGER MATTR, INTEGER XDELAY )
  1380. ****************************************************************************/
  1381. proc                          PopMessage( string title, integer mattr, integer xdelay )
  1382.           // by Richard Hendricks
  1383.   integer maxX, maxY, maxL, saveattr, boxtype, x1, y1, x2, y2, tlen, mlen
  1384.   if xdelay == 0
  1385.      msg = msg + ' ... press any key to continue.'
  1386.   endif
  1387.   maxX = Query( ScreenCols )
  1388.   maxY = Query( ScreenRows )
  1389.   tlen = length( title )
  1390.   mlen = length( msg )
  1391.   maxL = iif( tlen < mlen, mlen, tlen )
  1392.   x1 = (maxX - maxL - 3) / 2
  1393.   x1 = iif( x1<0, 0, x1)
  1394.   y1 = (maxY - 3) / 2
  1395.   y1 = iif( y1<0, 0, y1)
  1396.   x2 = x1 + maxL + 3
  1397.   y2 = y1 + 2
  1398.   boxtype = 6
  1399.   PopWinOpen( x1, y1, x2, y2, boxtype, title, query(hiliteattr) )
  1400.   saveattr = Query( Attr )
  1401.   Set( Attr, mattr )
  1402.   VHomeCursor()
  1403.   ClrScr()
  1404.   Set( Cursor, Off )
  1405.   Write( Format(" ":((maxL-length(msg)+3)/2))+msg ) // center msg
  1406.   if xdelay == 0
  1407.      GetKey()
  1408.   else
  1409.      delay(xdelay)
  1410.   endif
  1411.   Set( Attr, saveattr )
  1412.   PopWinClose()
  1413.   Set( Cursor, On )
  1414. end PopMessage
  1415.  
  1416. proc                          main()
  1417.      ClipBoardMenu()
  1418. end
  1419.  
  1420. /****************************************************************************
  1421.      KEY DEFS
  1422. ****************************************************************************/
  1423.  
  1424. <f11>          ClipBoardMenu()
  1425. <Grey*>        ClipBoard_Menu_Action( PASTE_APPEND )
  1426. <Ctrl Grey*>   ClipBoard_Menu_Action( Paste_OVERWRITE )
  1427. <Ctrl PrtSc>   ClipBoard_Menu_Action( Paste_OVERWRITE )
  1428. <Grey+>        ClipBoard_Menu_Action( Copy_OverWrite )
  1429. <Ctrl Grey+>   ClipBoard_Menu_Action( Copy_APPEND )
  1430. <Grey->        ClipBoard_Menu_Action( Cut_OverWrite )
  1431. <Ctrl Grey->   ClipBoard_Menu_Action( Cut_APPEND )